#include<iostream>
#include<vector>

using namespace std;

int findMinIndex(int i, vector<int> array) {
  int currentMin = i;
  for(int b = i+1; b < array.size(); b++) {
    if (array[b] < array[currentMin]) {
      currentMin = b;
    }
  }
  return currentMin;
}

vector<int> selectionSort(int i, vector<int> array) {
  if (i == array.size() - 1) {
    return array;
  }
  int j = findMinIndex(i, array);
  swap(array[i], array[j]);
  return selectionSort(i+1, array);
}

int main(int argc, char const *argv[]) {
  vector<int> array {1, 0, 2, -1, 8, 9, 22};
  for(int i : selectionSort(0, array)) {
    cout<<i<<" ";
  }
  return 0;
}

